package cn.fintecher.ams.service.attendance.service.impl;

import cn.fintecher.ams.service.attendance.common.ResponseResult;
import cn.fintecher.ams.service.attendance.exception.ServiceException;
import cn.fintecher.ams.service.attendance.mapper.UserMapper;
import com.github.pagehelper.PageHelper;
import cn.fintecher.ams.service.attendance.model.User;
import cn.fintecher.ams.service.attendance.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2017/4/17.
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserMapper userMapper;

    @Override
    public ResponseResult getUserByName(String userName) {
        return ResponseResult.wrap(userMapper.getUserByUserName(userName));
    }

    @Override
    public ResponseResult list(String userName, String realName, Integer page, Integer size) throws Exception {
        PageHelper.startPage(page,size);
        List<User> list = userMapper.list(realName,userName);
        if (list.size() == 0)
            throw new ServiceException("查无资料");
            //return ResponseResult.wrap(-999,"查无资料");
        return ResponseResult.wrap(list);//new PageInfo(list);
    }
}
